

<template>
<!-- 已经不用了20200702时间问的 -->
    <div class="storeInfo">
        <div class="head">
            <el-form :model="form" class="headForm">
                
                <el-form-item style="width:230px">
                    <el-date-picker
                        v-model="form.date"
                        type="month"
                        value-format="yyyy-MM"
                        placeholder="选择月份">
                    </el-date-picker>
                </el-form-item>

                <el-form-item label="" style="width:105px">
                    <el-select v-model="form.type" placeholder="商品分类">
                        <el-option v-for="(item,a) in catelist" :key="a" :label="item.cate_name" :value="item.category_id"></el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="" style="width:105px">
                <el-input v-model="form.item" placeholder="商品ID"></el-input>
                </el-form-item>

               
            <el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
            <el-button type="success"  @click="purchaseFn(2)">导出</el-button>
                
            </el-form>
            
        </div> 
        <!-- <p style="line-height:30px;padding-left:20px;margin-top:8px;color:#333" v-if="form.order_id == ''">最近{{total}}笔人工退款订单记录</p> -->
        <!-- table -->
        <div class="tabContainer_SI tabContainer">
            <el-table :data="tableData" stripe style="width: 100%;text-align:center" >
                <!-- 商品ID	商品	所属分类	采购量	赠送量	销售量	损耗量	损耗率				 -->
                <el-table-column prop="item_id" label="商品ID" fixed ></el-table-column>
                <el-table-column prop="item_name" label="商品名称" width="300px"> </el-table-column>
                <el-table-column prop="category_name" label="所属分类" ></el-table-column>
                <el-table-column prop="purchase_num" label="采购量"></el-table-column>
                <el-table-column prop="give_num" label="赠送量"></el-table-column>               
                <el-table-column prop="sale_num" label="销售量"></el-table-column>
                <el-table-column prop="wastage_num" label="损耗量" ></el-table-column>
                <el-table-column prop="wastage_rate" label="损耗率" :render-header="tableAction"></el-table-column>

            </el-table>                       
        </div>
        <!-- 分页部分 -->
        <el-pagination
            background
            layout="total, prev, pager, next, jumper"
            @current-change="changePage"
            :page-size="size"
            :current-page.sync="pageNum"
            :hide-on-single-page=true
            :total="total">{{total}}
        </el-pagination>


    </div>
</template>

<style lang="scss">
  .tabContainer_SI{
      .el-table{
          .cell{
              text-align: center;
          }
      }
  }
</style>

<script>
import Vue from 'vue';
import { abc } from "../../../../js/abc.js";
import {potUrl} from '../../../../js/config_url.js'; 


import HelpHint from '../../pop/HelpHint.vue'
let d = new Date();
let m = (d.getMonth()+1)>9?(d.getMonth()+1):'0'+(d.getMonth()+1)
let y = d.getFullYear()
let datenow = y+'-'+m;
console.log('ddd',y,m,datenow)
export default {
    components:{
        HelpHint
    },
    data () {
    return {
        searchparams:'',
        tableData:[],
        total:50,
        size:20,
        form:{size:20,
            page:1,
            date:datenow
        },
        pageNum:1,
        catelist:[],

    }
  }, 
   mounted(){
      let that = this;
      that.getList();
      abc.get(that,potUrl.categoryList,{},(res)=>{
          that.catelist = res.data
      })
  },
  methods:{
    search(){
        let that = this;
        //搜索有问题，搜索2019-03数据和2019-04数据是一样的；-error
        that.getList()
    },
    changePage(val){
        var that = this;
        that.pageNum = val;
        that.form.page = val;
        that.getList()
    },
    getList(){
        let that = this;
        abc.get(that,potUrl.itemstat,that.form,(res)=>{
            that.tableData=res.data.list;
            that.total = res.data.total;
        })//列表
    },
    tableAction() {
        return this.$createElement('HelpHint', {
            props: {
                content: '编辑车辆 / 删除车辆'
            }
        }, '操作');
    }
  }
}
</script>
